﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MSTestContrib.Specifications;
using System.Xml;

namespace GoGrid.Specifications
{
    [TestClass]
    [SpecificationDescription("BillingToken contains indicators of additional charges for GoGrid images.")]
    public class BillingTokenSpecification : GoGridSpecificationBase
    {
        [TestMethod]
        [ScenarioDescription("BillingTokenCreateFromXmlNode method correctly transforms sample XML fragment from Wiki site to object.")]
        [DeploymentItem("SampleData\\BillingTokenSample.xml")]
        public void BillingTokenCreateFromXmlNodeMethodCorrectlyTransformsSampleXmlFragmentFromWikiSiteToObject()
        {
            Given("a fragment of XML from the GoGrid wiki site", x => x.State.Fragment = LoadXmlFragment(x, "BillingTokenSample.xml"))
                .When("the CreateFromXmlNode method is called", x => x.State.BillingToken = BillingToken.CreateFromXmlNode(x.State.Fragment, null))
                .Then("the ID should equal 21", x => x.State.BillingToken.ID == 21)
                .And("the name should equal CentOS 5.1 64bit", x => x.State.BillingToken.Name == "CentOS 5.1 64bit")
                .And("the price should equal 0", x => x.State.BillingToken.Price == 0);
        }
    }
}
